import { text, integer } from 'drizzle-orm/sqlite-core/columns';
import { sqliteTable, index } from 'drizzle-orm/sqlite-core';

import { auditSchema } from './audit';

export const tableName = 'drivers';

export const definition = {
  id: text('id').primaryKey(),
  uid: text(),
  order: integer(),
  provider: text(),
  status: text(),
  remark: text(),
  disabled: integer('disabled', { mode: 'boolean' }),
  config: text('config', { mode: 'json' }).$type<{
    name: string,
  }>(),
};

export const table = sqliteTable(
  tableName,
  {
    ...definition,
    ...auditSchema,
  },
  (table) => [
    index('userDriverIndex').on(table.uid)
  ]
);
